<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>添加邮寄地址</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/index.css">
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/index.js"></script>

</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>姓名</label>
                <div class="layui-input-inline">
                    <input type="text" id="name" name="name" required="" lay-verify="nikename" autocomplete="off"
                           class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_email" class="layui-form-label">
                    <span class="x-red">*</span>收件人电话</label>
                <div class="layui-input-inline">
                    <input type="text" id="phone" name="phone" required="" lay-verify="email" autocomplete="off"
                           class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>省份</label>
                <div class="layui-input-inline">
                    <input type="text" id="province" name="province" required="" lay-verify="nikename"
                           autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>市</label>
                <div class="layui-input-inline">
                    <input type="text" id="city" name="city" required="" lay-verify="nikename" autocomplete="off"
                           class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>县/区</label>
                <div class="layui-input-inline">
                    <input type="text" id="county" name="county" required="" lay-verify="nikename" autocomplete="off"
                           class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>详细地址</label>
                <div class="layui-input-inline">
                    <input type="text" id="address" name="address" required="" lay-verify="nikename" autocomplete="off"
                           class="layui-input"></div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <input type="button" id="bu2" class="layui-btn"
                       onclick="xadmin.open('邮寄地址页面','menber-list.html',800,600)" value="确认添加">

            </div>
        </form>
    </div>
</div>

<script>
    document.getElementById("bu2").onclick = function () {
        var list = {
            "name": document.getElementById("name").value,
            "phone": document.getElementById("phone").value,
            "province": document.getElementById("province").value,
            "city": document.getElementById("city").value,
            "county": document.getElementById("county").value,
            "maddress": document.getElementById("address").value,
        };
        var lists = JSON.stringify(list);
        $.ajax({
            type: 'Post',
            // 如果使用这种url写法，则不需要再写在data中
            // url: '/test/getGoodsInfoByStatus?status=' + 1,

            url: 'http://localhost:5500/mailaddress/addAddress',
            data: lists,
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            success: function (result) {
                console.log(result);
                alert("添加成功");
            }, error: function (e) {//响应不成功时返回的函数
                console.log(e, 'error');
                alert("错误");
            }
        });

    };
</script>

</body>

</html>